package com.offen.controller;


import com.offen.entity.Course;
import com.offen.entity.Student;
import com.offen.service.ICourseService;
import com.offen.service.IStudentService;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lishucai
 * @since 2022-06-18
 */
@RestController
@RequestMapping("/offen/course")
public class CourseController {
    @Resource
    private ICourseService iCourseService;
   //查询所有
    @GetMapping
    public List<Course> getCouse(){
        List<Course> list = iCourseService.list();
        return list;
    }
   //添加信息
    @PutMapping("/uu")
    public boolean adduser(@RequestBody Course course){
        boolean save = iCourseService.save(course);
        return  save;
    }
    //删除信息
    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable  @RequestBody int id) {
        boolean b = iCourseService.removeById(id);
        return b;
    }
    //修改信息
    @PutMapping
    public Boolean update(@RequestBody Course ss) {
        return iCourseService.update(ss, iCourseService.update2(ss.getId()));
    }
}
